/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package captchabuster;

import java.io.*;
import java.util.*;
import java.util.StringTokenizer;

/**
 *
 * @author alexnewski
 */
public class Read {

    public File fFile;

    public Read(String aFileName) {
        fFile = new File(aFileName);
    }

    public Read() {
    }
//    

    public List<float[]> processLineByLine() throws FileNotFoundException, IOException {
        FileInputStream fis = new FileInputStream(fFile);
        DataInputStream dis = new DataInputStream(fis);
        BufferedReader br = new BufferedReader(new InputStreamReader(dis));
        List<float[]> list = new ArrayList<float[]>();
        String str = null;
        while ((str = br.readLine()) != null) {
            list.add(processLine(str));

        }
        return list;
    }
//    public List<float[]> processLineByLine() throws FileNotFoundException {
//             
//        
//        Scanner scanner = new Scanner(new FileReader(fFile));
//        List<float[]> list = new ArrayList<float[]>();
//        try {
//            while (scanner.hasNextLine()) {
//                list.add(processLine(scanner.nextLine()));
//            }
//        } finally {
//            scanner.close();
//            return list;
//        }
//    }

    public float[] processLine(String aLine) {
        StringTokenizer stok = new StringTokenizer(aLine, " ");
        float[] data = new float[18400];
        int count = 0;
        while (stok.hasMoreTokens()) {
            data[count] = Float.parseFloat(stok.nextToken());
            count++;
        }
        return data;
    }
//    public float[] processLine(String aLine) {
//        Scanner scanner = new Scanner(aLine);
//        scanner.useDelimiter(" ");
//        float[] data = new float[24750];
//        int count = 0;
//        while (scanner.hasNext()) {
//            data[count] = (Float.parseFloat(scanner.next().toString()));
//            count = count + 1;
//        }
//        //System.out.println(count);
//        return data;
//    }
}
